package com.moriarty.socketim.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;

import com.moriarty.socketim.R;
import com.moriarty.socketim.util.ThreadUtil;

/**
 * Created by Moriarty on 16/11/16.
 */

public class SplashActivity extends BaseActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.splash_activity);

        /**
         * 之前打开的时候黑屏 最后确认原因是因为开得是主线程那个方法runOnUIThread
         * 这样sleep就在主线程
         * 其实我总觉得setContentView这句话执行完 但实际上并没有加载完 要过一会儿才行（以前似乎有学过 忘了）
         */
        ThreadUtil.runOnSubThread(new Runnable() {
            @Override
            public void run() {
                try {
                    Thread.sleep(3000);
//                    Intent intent = new Intent(getBaseContext(), MainActivity.class);
//                    startActivity(intent);
                    startActivity(LoginActivity.class);
                    finish();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });
    }
}
